<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ include file="/WEB-INF/jsp/includes/common.jsp"%>
<html>
	<head>
		<%@ include file="/WEB-INF/jsp/includes/head.jsp"%>
		<script type="text/javascript" src="${ctx }/js/lib/jquery.ajaxfileupload.js"> </script>
		<script type="text/javascript">
		function ajaxUpload (){
			if($("#picture").val()==""){
				alert("请选择图片");
				return false;
			}
			$.ajaxFileUpload ({
				url :ctx+'/fileUploadSimple/ajaxUpload.do',
				secureuri :false,
				fileElementId :'picture',
				dataType : 'text',
				
				//接收两个值 success:url,error:msg
				success : function (data, status){
					alert(data);
					if(data.startWith("error")){
						alert(data);
					}else{
						$("#showdiv").show();
						$("#visitUrl").val(data);
						$("#img").attr("src",data);
					}
				},
				error: function (data, status, e){
					alert(1);
					alert(status);
				}
			})
			return false;
		}
		</script>
	</head>
	<body>
		<%@ include file="/WEB-INF/jsp/includes/logo.jsp"%>
		<div class="container">
			<div class="main clearfix">
			<%@ include file="/WEB-INF/jsp/includes/nav.jsp"%>	
				<div class="container2 fl">
					<div class="main">
					<h1>Please upload a file</h1>
					
						上传文件：<input type="file" id="picture" name="picture" /><br/>
						<input type="button" value="提交" onclick="ajaxUpload();"/>
					</div>
					<div  id="showdiv" style="display: none;">
					<img id="img" src="${visitUrl}"></img>
					<input type="text"  id="visitUrl"></input>
					</div>
				</div>
			</div>
		</div>
		
	
		
		<%@ include file="/WEB-INF/jsp/includes/bottom.jsp"%>
	</body>
</html>


